<?php
class Customer_model extends Model{

	var $_datagrid_name = 'dt1';
	var $orders_product = '';
	var $status = '';
    function Customer_model(){
        parent::Model();       
    }
	function getdatasource(){ 
    	$page = $this->input->post($this->_datagrid_name.'_hidden_page')?$this->input->post($this->_datagrid_name.'_hidden_page'):1;    	
    	$limit = $this->config->item('record_limit');   	
    	$count = $this->db->count_all('customer');    	
    	$pages = intval($count/$limit) + ($count%$limit?1:0);
    	$page = $page>$pages?1:$page;
    	$this->db->limit($limit,($page-1)*$limit);
		$this->db->select('id,fullname,createddate');
    	$this->db->order_by('createddate','DESC');	
		$query = $this->db->get('customer');
    	$datagrid->id = $this->_datagrid_name;
    	$datagrid->page = $page;
    	$datagrid->pages = $pages;		
    	$datagrid->datasource = $query->result_rowlist();
    	return $datagrid;    	
    }
	function delete(){
    	if($this->input->post($this->_datagrid_name.'_hidden_value')){
    		$id = $this->input->post($this->_datagrid_name.'_hidden_value');
    		$this->db->delete('customer',array('id'=>$id));
    	}
    	else if($this->input->post($this->_datagrid_name.'_chk_select')){
    		$id = $this->input->post($this->_datagrid_name.'_chk_select');
    		for($i=0;$i<count($id);$i++){
	    		$this->db->delete('customer',array('id'=>$id[$i]));
    		}
    	}
    }
    function getdetail($id){
		$str_query="select * from customer where customer.id='".$id."' ";
		$query = $this->db->query($str_query);
    	if($query->num_rows){
			$temp = '';
			$temp = $query->result();
    		return $temp[0];
    	}
    	else return FALSE;
    }   
}

/* End of file pricetable_model.php */
/* Location: ./system/application/admin/models/pricetable_model.php */